package chpt04.shapes;

public class ShapeTest {
	public static void main(String[] args) {
		Shape[] shapes = new Shape[3];
		shapes[0] = new Circle(2.0);
		shapes[1] = new Rectangle(3.0, 2.0);
		shapes[2] = new Circle(3.0);
		double area =  Shape.sumArea(shapes);
		System.out.println(area);
		
		// instanceof与强制转换演示
		for (int i = 0; i < shapes.length; i++) {
			if (shapes[i] instanceof Circle) {
				Circle x = (Circle)shapes[i];
				System.out.printf("shape[%d] is Circle", i);
				System.out.println("raidus is "+ x.getRadius());
			}
		}
		Object[] o = new String[5];
	}
}
